﻿@{
    var pageGroup = ViewData["PageGroup"] as CSCSN.DataAccess.Tool.PagenateGroup;
    // 提取控制器路径
    var controllerPath = "/" + ViewContext.RouteData.Values["controller"].ToString();

    // 缺省的列表页路径
    var defaultUrlString = controllerPath + "/TaskQueryList";
}
<style>
    .active a {
        background-color: green;
    }

    ul.pagination {
        display: inline-block;
        padding: 0;
        margin: 0;
    }

        ul.pagination li {
            display: inline;
        }

            ul.pagination li a {
                color: black;
                float: left;
                padding: 8px 16px;
                text-decoration: none;
            }

                ul.pagination li a.active {
                    background-color: #4CAF50;
                    color: white;
                }

                ul.pagination li a:hover:not(#active) {
                    background-color: #ddd;
                }
</style>
<br />
<br />
<nav class="Page navigation">

    <ul class="pagination">
        @if (pageGroup.PagenateGroupItem.FirstIndex == 1)//判断当前是否在第一组
        {
            if (pageGroup.PageIndex == 1)
            {
                <li class="page-item disabled"><a class="page-link" href="javascript:gotoPage('1')" aria-label="第一页"> <i class="fas fa-fast-backward"></i>首页</a></li>
            }
            else
            {
                <li class="page-item"><a class="page-link" href="javascript:appGotoDefaultPaginatePageForS('1','@defaultUrlString','mainWorkPlaceArea')" aria-label="第一页">首页 </a></li>
            }
            <li class="page-item disabled"><a class="page-link" href="#" aria-label="回退一组"><i class="fas fa-backward"></i>上组</a></li>
            if (pageGroup.PageIndex >= 2)//判断当前是否在第一页
            {
                <li class="page-item"><a class="page-link" href="javascript:appGotoDefaultPaginatePageForS('@(pageGroup.PageIndex-1)','@defaultUrlString','mainWorkPlaceArea')" aria-label="前一页"><i class="fas fa-play fa-rotate-180"></i>上页</a></li>
            }
            else
            {
                <li class="page-item disabled"><a class="page-link" href="#" aria-label="前一页"><i class="fas fa-play fa-rotate-180"></i>上页</a></li>
            }
        }
        else
        {
            <li class="page-item"><a class="page-link" href="javascript:appGotoDefaultPaginatePageForS('1','@defaultUrlString','mainWorkPlaceArea')" aria-label="第一页">首页 </a></li>
            <li class="page-item"><a class="page-link" href="javascript:appGotoDefaultPaginatePageForS('@(pageGroup.PageIndex-pageGroup.PagenateGroupItem.ItemIndexAmount)','@defaultUrlString','mainWorkPlaceArea')" aria-label="回退一组"><i class="fas fa-fast-backward">上组</i></a></li>
            <li class="page-item"><a class="page-link" href="javascript:appGotoDefaultPaginatePageForS('@(pageGroup.PageIndex-1)','@defaultUrlString','mainWorkPlaceArea')" aria-label="前一页"><i class="fas fa-play fa-rotate-180"></i>上页</a></li>
        }
        @for (int i = pageGroup.PagenateGroupItem.FirstIndex; i < pageGroup.PagenateGroupItem.LastIndex + 1; i++)//分页导航按钮（数字按钮）
        {
            var activeString = "";
            if (i == pageGroup.PageIndex)
            {
                activeString = "active";
                <li class="@activeString" id="active"><a href="javascript:appGotoDefaultPaginatePageForS('@i','@defaultUrlString','mainWorkPlaceArea')">@i </a></li>
            }
            else
            {
                <li id="active"><a class="page-link" href="javascript:appGotoDefaultPaginatePageForS('@i','@defaultUrlString','mainWorkPlaceArea')">@i <span class="sr-only">(current)</span></a></li>
            }
        }
        @if (pageGroup.PagenateGroupItem.LastIndex == pageGroup.PageAmount)
        {
            if (pageGroup.PageIndex < pageGroup.PageAmount)
            {
                <li class="page-item"><a class="page-link" href="javascript:appGotoDefaultPaginatePageForS('@(pageGroup.PageIndex+1)','@defaultUrlString','mainWorkPlaceArea')" aria-label="后一页"><i class="fas fa-play"></i>下页</a></li>
            }
            else
            {
                <li class="page-item disabled"><a class="page-link" href="#" aria-label="下一页"><i class="fas fa-play"></i>下页</a></li>
            }
            <li class="page-item disabled"><a class="page-link" href="#" aria-label="向前一组"><i class="fas fa-forward"></i>下组</a></li>
            <li class="page-item disabled"><a class="page-link" href="#" aria-label="最后页"><i class="fas fa-fast-forward"></i>尾页</a></li>
        }
        else
        {
            <li class="page-item"><a class="page-link" href="javascript:appGotoDefaultPaginatePageForS('@(pageGroup.PageIndex+1)','@defaultUrlString','mainWorkPlaceArea')" aria-label="后一页"><i class="fas fa-play"></i>下页</a></li>
            <li class="page-item"><a class="page-link" href="javascript:appGotoDefaultPaginatePageForS('@(pageGroup.PageIndex+pageGroup.PagenateGroupItem.ItemIndexAmount)','@defaultUrlString','mainWorkPlaceArea')" aria-label="向前一组"><i class="fas fa-forward"></i>下组</a></li>
            <li class="page-item"><a class="page-link" href="javascript:appGotoDefaultPaginatePageForS('@pageGroup.PageAmount','@defaultUrlString','mainWorkPlaceArea')" aria-label="最后一条"><i class="fas fa-fast-forward"></i>尾页</a></li>
        }

    </ul>
</nav>
